from classfile.constant_info import ConstantInfo


class ConstantIntegerInfo(ConstantInfo):
    def __init__(self):
        super().__init__()
        self.val = 0

    def readInfo(self, clsReader):
        self.val = int(clsReader.readU32())

    def getValue(self):
        return self.val


class ConstantFloatInfo(ConstantInfo):
    def __init__(self):
        super().__init__()
        self.val = 0.0

    def readInfo(self, clsReader):
        self.val = float(clsReader.readU32())

    def getValue(self):
        return self.val


class ConstantLongInfo(ConstantInfo):
    def __init__(self):
        super().__init__()
        self.val = 0

    def readInfo(self, clsReader):
        self.val = int.from_bytes(clsReader.readU64(), "big")

    def getValue(self):
        return self.val


class ConstantDoubleInfo(ConstantInfo):
    def __init__(self):
        super().__init__()
        self.val = 0

    def readInfo(self, clsReader):
        self.val = float.fromhex(clsReader.readU64())

    def getValue(self):
        return self.val
